package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.ClasseWork;
import com.indusfo.spc.service.ClasseWorkService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 班次开工控制层
 */

@Controller
@RequestMapping("/service/classeWork")
public class ClasseWorkController {

    @Autowired
    private ClasseWorkService classeWorkService;


    /**
     * 批量登出
     *
     * @param classeWorkIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value = "/classeWorkLogout",method= RequestMethod.POST)
    @SystemControllerLog(description="登出班次开工")
    @ResponseBody
    public JSONObject logoutClasseWork(Long[] classeWorkIds, Integer logoutUserId) {
        JSONObject json = classeWorkService.logoutClasseWork(classeWorkIds, logoutUserId);
        return json;
    }

    /**
     * 查询
     *
     * @param classeWork
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/queryClasseWork")
    @SystemControllerLog(description="查询班次开工")
    @ResponseBody
    public JSONObject queryClasseWork(ClasseWork classeWork) {
        JSONObject json = classeWorkService.selectAll(classeWork);
        return json;

    }

    /**
     * 登入
     *
     * @param classeWork
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/insertClasseWork", method= RequestMethod.POST)
    @SystemControllerLog(description="登入班次开工")
    @ResponseBody
    public JSONObject insertClasseWork(ClasseWork classeWork) {
        JSONObject json = classeWorkService.insertClasseWork(classeWork);
        return json;
    }

    /**
     * 启用/停用
     *
     * @param classeWorkIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/definedClasseWork", method= RequestMethod.POST)
    @SystemControllerLog(description="启用/停用班次开工")
    @ResponseBody
    public JSONObject definedClasseWork(Long[] classeWorkIds, Integer dataState) {
        JSONObject json = classeWorkService.definedClasseWork(classeWorkIds, dataState);
        return json;
    }

    /**
     * 删除
     *
     * @param classeWorkIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/deleteClasseWork", method= RequestMethod.POST)
    @SystemControllerLog(description="删除班次开工")
    @ResponseBody
    public JSONObject deleteClasseWork(Long[] classeWorkIds, Integer dataState) {
        dataState = 2;
        JSONObject json = classeWorkService.definedClasseWork(classeWorkIds, dataState);
        return json;
    }

    /**
     * 查询
     *
     * @param classeId
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/queryClasseHour")
    @SystemControllerLog(description="查询班次时间")
    @ResponseBody
    public JSONObject queryClasseHour(Integer classeId) {
        JSONObject json = classeWorkService.queryClasseHour(classeId);
        return json;

    }
}
